<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@page import="com.cap.bts.framework.usermgnt.constant.EmployeeStatus"%>    
    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>人员维护</title>
<%@include file="../../include/include.jsp"%>
<link rel="stylesheet" type="text/css" href="${csspath }/public.css"/>
<link rel="stylesheet" type="text/css" href="${csspath }/datepicker.css"/>
<link rel="stylesheet" type="text/css" href="${csspath }/style_l.css"/>
<script type="text/javascript" src="${jspath }/jquery-1.4.4.js"></script>
<script type="text/javascript" src="${jspath }/jquery.ui.min.js"></script>
<script type="text/javascript" src="${jspath }/ui.datepicker_zh-CN.js"></script>
<script type="text/javascript" src="${jspath }/jquery.blockUI.js"></script>
<script type="text/javascript" src="${jspath }/public.js"></script>
<script type="text/javascript" src="${jspath }/jquery.selectAll.js"></script>
<script type="text/javascript" src="${jspath}/jquery/jquery.ui.draggable.js"></script>
<script type="text/javascript" src="${jspath}/jquery/jquery.alerts.js"></script>
<link rel="stylesheet" type="text/css" href="${csspath}/jquery.alerts.css" />

<link rel="stylesheet" type="text/css"
	href="${webcontext}/css/validationEngine.jquery.css" />
<script src="${jspath}/jquery/validate/jquery.validationEngine.js"
	type="text/javascript"></script>
<script src="${jspath}/jquery/validate/jquery.validationEngine-zh.js"
	type="text/javascript"></script>
	<script type="text/javascript"
	src="${webcontext}/javascript/jquery/jquery.ui.draggable.js"></script>
<style type="text/css">
.formError .formErrorContent {
    -moz-border-radius: 6px 6px 6px 6px;
    -moz-box-shadow: 0 0 6px #000000;
    background: none repeat scroll 0 0 #EE0101;
    border: 2px solid #DDDDDD;
    color: #FFFFFF;
    font-family: tahoma;
    font-size: 11px;
    padding: 4px 10px;
    width: 100px;
}
</style>

<script type="text/javascript">
var myHeight = 0;
$(function(){
	
	$("#search_form").validationEngine(
			{
             promptPosition:"topLeft",
             success:false,
             validationEventTriggers:"blur",
             scroll : false,
			 failure:function(){} 
	});
	
	$("#selectUserGroup").click(function(){
		
		openWindow("${webcontext}/common/getDefaultUserGroupPage?outputid=userGroupCode");
		
	});
	
	$("#selectRoleCode").click(function(){
		
		openWindow("${webcontext}/common/getDefaultRolePage?outputid=roleCode");
		
	});
	
	$("#selectOrgCode").click(function(){
		
		openWindow("${webcontext}/common/getDefaultOrgPage?outputid=orgCode");
		
	});
	
	$("#add").click(function(){
		$(this).attr("href", "${webcontext}/dm/dealer/employeemgnt/createEmployeePage");
		
	});
	 
	
 $("#delete").click(function(){
	 
		if ($(":radio:checked").length > 0)
		{  
	        
			if (($(":radio:checked").attr("workStatus") == "<%= EmployeeStatus.NORMAL %>"))
		    {
				 jAlert("不能删除正式员工！","提示信息");
				 return;
		    }
			jConfirm("确认删除此记录？","确认提示",function(result){
	    		if(result == true)
	    		{	
	    			$.get("${webcontext}/dm/dealer/employeemgnt/deleteEmployee?employeeId="+$(":radio:checked").val(),
	        			    function(data) {
	        				if (data == "1")
	        			    {
	        					search();
	        			    }
	        				    
	                 });	
	    		}
	    	});
			
		}else {
			
		    jAlert("请选择人员记录！","提示信息");
		} 
 });
	
 
 $("#detail").click(function(){
	 
	 if ($(":radio:checked").length > 0)
		{  
		 
		  $(this).attr("href", "${webcontext}/common/getEmployeeDetailByUserId?userId=" + $(":radio:checked").attr("userId"));
		 
		}else {
			
		    jAlert("请选择人员记录！","提示信息");
		} 
 });
 
	
});

function search(){
	document.getElementById("search_form").submit();
}

</script> 
</head>
<body>

	<!-- content -->
	<div id="content">
		<!-- wrap -->
		<div id="wrap">

			<!-- breadcrumb -->
			<div id="breadcrumb">
				<span>人员维护</span>
			</div>

			<!-- /breadcrumb -->
			<!-- search_div -->
			<form:form id="search_form" action="${webcontext}/dm/dealer/employeemgnt/toMaintainEmployeePage" method="post" modelAttribute="dto">
			<div class="search_div">
				<div class="spliter h_10"></div>
				<table class="search_tab">
					<tr>
					  <td class="label">用户ID：</td>
					  <td><form:input path="userCode" cssClass="validate[length[0,17]] text string"/></td>
					  <td class="label">员工姓名：</td>
					  <td><form:input path="name" cssClass="validate[length[0,90]] text string"/></td>
					  <td class="label">手机：</td>
					  <td><form:input path="mobilePhone" cssClass="validate[custom[NullOrMobile]]  text string"/></td>
					  <td class="label">性别：</td>
					  <td>
					  	<form:select path="gender" cssClass="sel">  
					  	 <form:option value="0">请选择</form:option>
				        <core:forEach items="${gender}" var="codeInfo">
				         <form:option value="${codeInfo.id }">${codeInfo.value }</form:option>
				        </core:forEach>	
						</form:select>
					  </td>
					  
				  </tr>
					<tr>
					  <td class="label">岗位：</td>
					  <td><form:input path="userGroupCode" cssClass="validate[length[0,30]] text string"/><img id="selectUserGroup" src="${webcontext}/images/pictures_l/question.gif" alt="" class="help" /></td>
					  <td class="label">角色：</td>
					  <td><form:input path="roleCode" cssClass="validate[length[0,40]] text string"/><img id="selectRoleCode" src="${webcontext}/images/pictures_l/question.gif" alt="" class="help" /></td>
					  <td class="label">组织：</td>
					  <td><form:input path="orgCode" cssClass="validate[length[0,30]] text string"/><img id="selectOrgCode" src="${webcontext}/images/pictures_l/question.gif" alt="" class="help" /></td>
					  <td class="label">就业状态：</td>
					  <td>
					    <form:select path="workStatus" class="sel">  
					  	 <form:option value="0">请选择</form:option>
				        <%= CodeTextUtils.getOptions("Employee.WorkStatus","" ) %>
						</form:select>
						<script type="text/javascript">
						$("#workStatus").val("${dto.workStatus}");
						</script>
					  </td>
				  </tr>
					<tr>
						<td colspan="8" class="center2">
							<input type="submit" class="btn" value="查询"/>&nbsp;&nbsp;<input type="reset" class="btn" value="重置"/>
						</td>
					</tr>
				</table>
				<div class="spliter h_10"></div>
			</div>
			<!-- /search_div -->
		
			<div class="spliter h_10"></div>
			<!-- page_div -->

			<div class="page_div">
				<div class="page_info">
                    <a class="add" id="add">新增</a>
                    <a  id="detail" class="search">详情</a>
			  		<a  id="delete" class="delete">删除</a>
                </div> 
				<div class="page_opts">
                   <%@include file="../../common/headerpage.jsp"%>		
				</div>
			</div>
			<!-- /page_div -->
			<!-- data_div -->
			<div class="data_div">
				<table class="data_tab">

					<tr>
						<th width="3%">选择</th>
                        <th width="6%">用户ID</th>
						<th width="8%">员工姓名</th>
						<th width="5%">岗位</th>
						<th width="8%">就业状态</th>
                        <th width="5%">组织</th>
                        <th width="9%">手机</th>
                        <th width="8%">婚姻状况</th>
                        <th width="4%" >学历</th>
                        <th width="8%">生日</th>
                        <th width="22%">住址</th>
                    </tr>
                  <core:forEach items="${empResultDtoList}" var="empResultDto">
					<tr>
						<td class="align_m"><input type="radio" name="id" class="select_one" value="${empResultDto.id}" workStatus="${empResultDto.employmentStatusId }" userId="${empResultDto.userId }"/></td>
                         <td>${empResultDto.userCode}</td>
                        <td>${empResultDto.userName}</td>
                        <td>
                         <core:forEach items="${empResultDto.userGroupList}" var="userGroup">
                          ${userGroup.userGroupName}<br />
                         </core:forEach>
                        </td>
                        <td>${ empResultDto.employmentStatus }</td>
                        <td>
                         <core:forEach items="${empResultDto.orgList}" var="org">
                         ${org.orgName}<br />
                        </core:forEach>
                        </td>
                        <td>${ empResultDto.mobilePhone }</td>
                        <td>${ empResultDto.marrige }</td>
                        <td>${ empResultDto.education }</td>
                        <td><fmt:formatDate value="${empResultDto.birthDate}" pattern="yyyy-MM-dd" /></td>
                        <td class="">${empResultDto.address}</td>
                    </tr>
                 </core:forEach>                    
                    
				</table>
</div>
			<!-- /data_div -->
            
            <!-- page_div -->
			<div class="page_div">
			    <%@include file="../../common/page.jsp"%>
			</div>
			<!-- /page_div -->
           </form:form>
		</div>
		<!-- /wrap -->
	</div>
	<!-- /content -->

  </body>

</html>